home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / WFC010.ZIP / INCLUDE / CTAPE.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-07  |  7.6 KB  |  246 lines

  1. #if ! defined( TAPE_CLASS_HEADER )
  2.  
  3. /*
  4. ** Author: Samuel R. Blackburn
  5. ** CI$: 76300,326
  6. ** Internet: sammy@sed.csc.com
  7. **
  8. ** You can use it any way you like as long as you don't try to sell it.
  9. **
  10. ** Any attempt to sell WFC in source code form must have the permission
  11. ** of the original author. You can produce commercial executables with
  12. ** WFC but you can't sell WFC.
  13. **
  14. ** Copyright, 1995, Samuel R. Blackburn
  15. **
  16. ** $Workfile: $
  17. ** $Revision: $
  18. ** $Modtime: $
  19. */
  20.  
  21. #define TAPE_CLASS_HEADER
  22.  
  23. class CTapeGetDriveParameters : public _TAPE_GET_DRIVE_PARAMETERS
  24. {
  25.    public:
  26.  
  27.       CTapeGetDriveParameters();
  28.       CTapeGetDriveParameters( const CTapeGetDriveParameters& source );
  29.       CTapeGetDriveParameters( const TAPE_GET_DRIVE_PARAMETERS * source );
  30.  
  31.       virtual ~CTapeGetDriveParameters();
  32.  
  33.       virtual void Copy( const CTapeGetDriveParameters& source );
  34.       virtual void Copy( const TAPE_GET_DRIVE_PARAMETERS * source );
  35.       virtual void Empty( void );
  36.  
  37. #if defined( _DEBUG )
  38.  
  39.       virtual void Dump( CDumpContext& dump_context ) const;
  40.  
  41. #endif
  42. };
  43.  
  44. class CTapeGetMediaParameters : public _TAPE_GET_MEDIA_PARAMETERS
  45. {
  46.    public:
  47.  
  48.       CTapeGetMediaParameters();
  49.       CTapeGetMediaParameters( const CTapeGetMediaParameters& source );
  50.       CTapeGetMediaParameters( const TAPE_GET_MEDIA_PARAMETERS * source );
  51.  
  52.       virtual ~CTapeGetMediaParameters();
  53.  
  54.       virtual void Copy( const CTapeGetMediaParameters& source );
  55.       virtual void Copy( const TAPE_GET_MEDIA_PARAMETERS * source );
  56.       virtual void Empty( void );
  57.  
  58. #if defined( _DEBUG )
  59.  
  60.       virtual void Dump( CDumpContext& dump_context ) const;
  61.  
  62. #endif
  63. };
  64.  
  65. class CTapeSetDriveParameters : public _TAPE_SET_DRIVE_PARAMETERS
  66. {
  67.    public:
  68.  
  69.       CTapeSetDriveParameters();
  70.       CTapeSetDriveParameters( const CTapeSetDriveParameters& source );
  71.       CTapeSetDriveParameters( const TAPE_SET_DRIVE_PARAMETERS * source );
  72.  
  73.       virtual ~CTapeSetDriveParameters();
  74.  
  75.       virtual void Copy( const CTapeSetDriveParameters& source );
  76.       virtual void Copy( const TAPE_SET_DRIVE_PARAMETERS * source );
  77.       virtual void Empty( void );
  78.  
  79. #if defined( _DEBUG )
  80.  
  81.       virtual void Dump( CDumpContext& dump_context ) const;
  82.  
  83. #endif
  84. };
  85.  
  86. class CTapeSetMediaParameters : public _TAPE_SET_MEDIA_PARAMETERS
  87. {
  88.    public:
  89.  
  90.       CTapeSetMediaParameters();
  91.       CTapeSetMediaParameters( const CTapeSetMediaParameters& source );
  92.       CTapeSetMediaParameters( const TAPE_SET_MEDIA_PARAMETERS * source );
  93.  
  94.       virtual ~CTapeSetMediaParameters();
  95.  
  96.       virtual void Copy( const CTapeSetMediaParameters& source );
  97.       virtual void Copy( const TAPE_SET_MEDIA_PARAMETERS * source );
  98.       virtual void Empty( void );
  99.  
  100. #if defined( _DEBUG )
  101.  
  102.       virtual void Dump( CDumpContext& dump_context ) const;
  103.  
  104. #endif
  105. };
  106.  
  107. class CTape : public CDummyFile
  108. {
  109.    private:
  110.  
  111.       void m_Initialize( void );
  112.  
  113.    protected:
  114.  
  115.       LPVOID m_BackupReadContextPointer;
  116.       LPVOID m_BackupWriteContextPointer;
  117.  
  118.       BOOL m_AutomaticallyClose;
  119.       
  120.    public:
  121.  
  122.       CTape();
  123.  
  124.       virtual ~CTape();
  125.  
  126.       enum TypeOfPartition
  127.       {
  128.          Fixed     = TAPE_FIXED_PARTITIONS,
  129.          Initiator = TAPE_INITIATOR_PARTITIONS,
  130.          Select    = TAPE_SELECT_PARTITIONS 
  131.       };
  132.  
  133.       enum TypeOfErasure
  134.       {
  135.          Long  = TAPE_ERASE_LONG,
  136.          Short = TAPE_ERASE_SHORT
  137.       };
  138.  
  139.       enum TypeOfMark
  140.       {
  141.          File      = TAPE_FILEMARKS,
  142.          LongFile  = TAPE_LONG_FILEMARKS,
  143.          Set       = TAPE_SETMARKS,
  144.          ShortFile = TAPE_SHORT_FILEMARKS
  145.       };
  146.  
  147.       enum Position
  148.       {
  149.          Absolute = TAPE_ABSOLUTE_POSITION,
  150.          Logical  = TAPE_LOGICAL_POSITION
  151.       };
  152.  
  153.       enum PositionMethod
  154.       {
  155.          AbsoluteBlock       = TAPE_ABSOLUTE_BLOCK,
  156.          LogicalBlock        = TAPE_LOGICAL_BLOCK,
  157.          Rewind              = TAPE_REWIND,
  158.          EndOfData           = TAPE_SPACE_END_OF_DATA,
  159.          FileMarks           = TAPE_SPACE_FILEMARKS,
  160.          RelativeBlocks      = TAPE_SPACE_RELATIVE_BLOCKS,
  161.          SequentialFileMarks = TAPE_SPACE_SEQUENTIAL_FMKS,
  162.          SequentialSetMarks  = TAPE_SPACE_SEQUENTIAL_SMKS,
  163.          SetMarks            = TAPE_SPACE_SETMARKS
  164.       };
  165.  
  166.       enum Operation
  167.       {
  168.          FormatTape  = TAPE_FORMAT,
  169.          LoadTape    = TAPE_LOAD,
  170.          LockTape    = TAPE_LOCK,
  171.          TensionTape = TAPE_TENSION,
  172.          UnloadTape  = TAPE_UNLOAD,
  173.          UnlockTape  = TAPE_UNLOCK
  174.       };
  175.  
  176.       /*
  177.       ** The Win32 API
  178.       */
  179.  
  180.       virtual BOOL CreatePartition( const TypeOfPartition type_of_partition,
  181.                                     const DWORD number_of_partitions,
  182.                                     const DWORD number_of_megabytes_in_each_partition ); // CreateTapePartition
  183.  
  184.       virtual BOOL Erase( const TypeOfErasure type_of_erasure, const BOOL return_immediately = FALSE ); // EraseTape
  185.  
  186.       virtual BOOL GetParameters( CTapeGetDriveParameters& parameters ); // GetTapeParameters
  187.       virtual BOOL GetParameters( CTapeGetMediaParameters& parameters );
  188.  
  189.       virtual BOOL GetPosition( const Position type_of_position_to_get,
  190.                                 DWORD& partition_number,
  191.                                 DWORD& position_low,
  192.                                 DWORD& position_high ); // GetTapePosition
  193.  
  194.       virtual DWORD GetStatus( void ) const; // GetTapeStatus
  195.  
  196.       virtual BOOL Prepare( const Operation what_to_do, const BOOL return_immediately = FALSE ); // PrepareTape
  197.  
  198.       virtual BOOL SetAutomaticallyClose( BOOL auto_close ); // returns previous setting
  199.       virtual BOOL SetParameters( const CTapeSetDriveParameters& parameters ); // SetTapeParameters
  200.       virtual BOOL SetParameters( const CTapeSetMediaParameters& parameters );
  201.  
  202.       virtual BOOL SetPosition( const PositionMethod how_to_get_there, 
  203.                                 const DWORD          partition_number,
  204.                                 const DWORD          position_low,
  205.                                 const DWORD          position_high,
  206.                                 const BOOL           return_immediately = FALSE ); // SetTapePosition
  207.  
  208.       virtual BOOL Mark( const TypeOfMark type_of_mark, 
  209.                          const DWORD      number_of_marks_to_write, 
  210.                          const BOOL       return_immediately = FALSE ); // WriteTapemark
  211.  
  212.       virtual BOOL Read( LPBYTE      buffer, 
  213.                          const DWORD number_of_bytes_to_read,
  214.                          LPDWORD     number_of_bytes_read,
  215.                          BOOL        abort = FALSE,
  216.                          BOOL        restore_security_data = TRUE ); // BackupRead
  217.  
  218.       virtual BOOL Seek( const DWORD seek_low,
  219.                          const DWORD seek_high,
  220.                          LPDWORD seeked_low,
  221.                          LPDWORD seeked_high ); // BackupSeek
  222.  
  223.       virtual BOOL Write( LPBYTE      buffer,
  224.                           const DWORD number_of_bytes_to_write,
  225.                           LPDWORD     number_of_bytes_written,
  226.                           BOOL        abort = FALSE,
  227.                           BOOL        restore_security_data = TRUE ); // BackupWrite
  228.  
  229.       /*
  230.       ** API's to make life easier
  231.       */
  232.  
  233.       virtual BOOL Open( const UINT tape_drive_number_starting_at_zero ); // Calls Prepare( TAPE_LOAD )
  234.       virtual BOOL Load( void );
  235.       virtual BOOL Lock( void );
  236.       virtual BOOL Unload( void );
  237.       virtual BOOL Unlock( void );
  238.       virtual void Close( void ); // Calls Prepare( TAPE_UNLOAD )
  239.  
  240.       /*
  241.       ** Operators
  242.       */
  243. };
  244.  
  245. #endif // TAPE_CLASS_HEADER
  246.